home *** CD-ROM | disk | FTP | other *** search
- //---------------------------------------------------------------------------
- // BmpFilm.c
- //---------------------------------------------------------------------------
- // Contains control procedure for BmpFilm control
- //---------------------------------------------------------------------------
-
- #include <windows.h>
- #include "vbapi.h"
- #include "BmpFilm.h"
-
- //---------------------------------------------------------------------------
- // Local Prototypes
- //---------------------------------------------------------------------------
- BOOL _export FAR PASCAL AboutDlgProc(HWND hDlg, USHORT msg, USHORT wp, LONG lp);
-
- //---------------------------------------------------------------------------
- // Global Variables
- //---------------------------------------------------------------------------
- HANDLE hmodDLL;
-
- //---------------------------------------------------------------------------
- // BmpFilm Control Procedure
- //---------------------------------------------------------------------------
- LONG FAR PASCAL _export BmpFilmCtlProc
- (
- HCTL hctl,
- HWND hwnd,
- USHORT msg,
- USHORT wp,
- LONG lp
- )
- {
- LPBmpFilm BmpFilm;
- BmpFilm = LpBmpFilmDEREF(hctl);
- switch (msg)
- {
- case WM_NCCREATE:
- BmpFilm->Col = 0;
- BmpFilm->Row = 0;
- VBSetControlProperty(hctl, IPROP_BmpFilm_Interval, 200);
- VBSetControlProperty(hctl, IPROP_BmpFilm_Cols, 3);
- VBSetControlProperty(hctl, IPROP_BmpFilm_Rows, 6);
- break;
- case WM_TIMER:
- if (BmpFilm->Row==BmpFilm->Rows-1)
- {
- BmpFilm->Row = 0;
- BmpFilm->Col++;
- }
- else BmpFilm->Row++;
- if (BmpFilm->Col==BmpFilm->Cols)
- {
- BmpFilm->Row = 0;
- BmpFilm->Col = 0;
- }
- InvalidateRect(hwnd, NULL, FALSE);
- break;
- case WM_PAINT:
- {
- PAINTSTRUCT ps;
- HDC MemDC;
- HBRUSH hBrush;
- HBRUSH hBrushOld;
- RECT rect;
- PIC Pic;
- HPIC hPic;
- BITMAP Bmp;
- if (VBGetMode()==MODE_RUN) VBFireEvent(hctl, IEVENT_BmpFilm_Paint, NULL);
- BeginPaint(hwnd, &ps);
- VBGetControlProperty(hctl, IPROP_BmpFilm_Picture, &hPic);
- if (hPic!=0)
- {
- VBGetPic(hPic, &Pic);
- hBrush = (HBRUSH)GetBrushOrg(ps.hdc);
- if (hBrush) hBrushOld = SelectObject(ps.hdc, hBrush);
- GetClientRect(hwnd, &rect);
- GetObject(Pic.picData.bmp.hbitmap, sizeof(BITMAP), (LPSTR)&Bmp);
- MemDC = CreateCompatibleDC(ps.hdc);
- SelectObject(MemDC, Pic.picData.bmp.hbitmap);
- BitBlt(ps.hdc,0,0,Bmp.bmWidth / BmpFilm->Rows,Bmp.bmHeight / BmpFilm->Cols,MemDC
- ,BmpFilm->Row*(Bmp.bmWidth / BmpFilm->Rows),BmpFilm->Col*(Bmp.bmHeight / BmpFilm->Cols),SRCCOPY);
- SelectObject(ps.hdc, hBrushOld);
- DeleteDC(MemDC);
- }
- EndPaint(hwnd, &ps);
- }
- break;
- case VBM_SETPROPERTY:
- {
- switch (wp)
- {
- case IPROP_BmpFilm_Picture:
- InvalidateRect(hwnd, NULL, TRUE);
- break;
- case IPROP_BmpFilm_Interval:
- if (VBGetMode()==MODE_RUN)
- {
- VBGetControlProperty(hctl, IPROP_BmpFilm_Interval, &BmpFilm->Interval);
- SetTimer(hwnd, 100, BmpFilm->Interval, NULL);
- }
- break;
- case IPROP_BmpFilm_Cols:
- VBGetControlProperty(hctl, IPROP_BmpFilm_Cols, &BmpFilm->Cols);
- InvalidateRect(hwnd, NULL, TRUE);
- break;
- case IPROP_BmpFilm_Rows:
- VBGetControlProperty(hctl, IPROP_BmpFilm_Rows, &BmpFilm->Rows);
- InvalidateRect(hwnd, NULL, TRUE);
- break;
- }
- }
- break;
- case WM_USER:
- VBDialogBoxParam(hmodDLL, "ABOUT", (FARPROC)AboutDlgProc, 0L);
- break;
- case VBM_INITPROPPOPUP:
- if (wp==3)
- {
- PostMessage(hwnd,WM_USER,0,0);
- return (lp+1)&&(0xFFFF);
- }
- break;
- }
- return VBDefControlProc(hctl, hwnd, msg, wp, lp);
- }
- // This routine handles the 'About' Dialog Box messages
- BOOL FAR PASCAL _export AboutDlgProc
- (
- HWND hDlg,
- USHORT msg,
- USHORT wp,
- LONG lp
- )
- {
- switch (msg)
- {
- case WM_CREATE:
- // Avoid warnings on unused (but required) formal parameters
- lp = lp;
- return TRUE;
- case WM_INITDIALOG:
- return FALSE;
- case WM_COMMAND:
- if ((wp==IDOK)||(wp==IDCANCEL))
- EndDialog(hDlg, TRUE);
- return TRUE;
- }
- return FALSE;
- }
- //---------------------------------------------------------------------------
- // Register custom control. This routine is called by VB when the custom
- // control DLL is loaded for use.
- //---------------------------------------------------------------------------
- BOOL FAR PASCAL _export VBINITCC
- (
- USHORT usVersion,
- BOOL fRuntime
- )
- {
- // Avoid warnings on unused (but required) formal parameters
- fRuntime = fRuntime;
- usVersion = usVersion;
- // Register control(s)
- return VBRegisterModel(hmodDLL, &modelBmpFilm);
- }
-
-
- //---------------------------------------------------------------------------
- // Initialize library. This routine is called when the first client loads
- // the DLL.
- //---------------------------------------------------------------------------
- int FAR PASCAL LibMain
- (
- HANDLE hModule,
- WORD wDataSeg,
- WORD cbHeapSize,
- LPSTR lpszCmdLine
- )
- {
- // Avoid warnings on unused (but required) formal parameters
- wDataSeg = wDataSeg;
- cbHeapSize = cbHeapSize;
- lpszCmdLine = lpszCmdLine;
-
- hmodDLL = hModule;
-
- return 1;
- }
- //---------------------------------------------------------------------------
- // WEP
- //---------------------------------------------------------------------------
- // C7 and QCWIN provide default a WEP:
- //---------------------------------------------------------------------------
- #if (_MSC_VER < 610)
- int FAR PASCAL WEP(int fSystemExit);
- //---------------------------------------------------------------------------
- // For Windows 3.0 it is recommended that the WEP function reside in a
- // FIXED code segment and be exported as RESIDENTNAME. This is
- // accomplished using the alloc_text pragma below and the related EXPORTS
- // and SEGMENTS directives in the .DEF file.
- //
- // Read the comments section documenting the WEP function in the Windows
- // 3.1 SDK "Programmers Reference, Volume 2: Functions" before placing
- // any additional code in the WEP routine for a Windows 3.0 DLL.
- //---------------------------------------------------------------------------
- #pragma alloc_text(WEP_TEXT,WEP)
- //---------------------------------------------------------------------------
- // Performs cleanup tasks when the DLL is unloaded. WEP() is
- // called automatically by Windows when the DLL is unloaded (no
- // remaining tasks still have the DLL loaded). It is strongly
- // recommended that a DLL have a WEP() function, even if it does
- // nothing but returns success (1), as in this example.
- //---------------------------------------------------------------------------
- int FAR PASCAL WEP
- (
- int fSystemExit
- )
- {
- // Avoid warnings on unused (but required) formal parameters
- fSystemExit = fSystemExit;
- return 1;
- }
- #endif // C6
- //---------------------------------------------------------------------------
-